// Copyright (C) 2024 Kumo inc.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#pragma once

#include <turbo/log/logging.h>
#include <turbo/log/flags.h>
#include <turbo/flags/flag.h>
#include <turbo/strings/str_format.h>


#define SLT_INF(slot, fmt, ...) LOG(INFO)<<NOPREFIX<<NONEWLINE<<turbo::str_format("slot %12.*s: id %2d | task %d | " fmt, 12, __func__, (slot).id, (slot).id_task, __VA_ARGS__)
#define SLT_WRN(slot, fmt, ...) LOG(WARNING)<<NOPREFIX<<NONEWLINE<<turbo::str_format("slot %12.*s: id %2d | task %d | " fmt, 12, __func__, (slot).id, (slot).id_task, __VA_ARGS__)
#define SLT_ERR(slot, fmt, ...) LOG(ERROR)<<NOPREFIX<<NONEWLINE<<turbo::str_format("slot %12.*s: id %2d | task %d | " fmt, 12, __func__, (slot).id, (slot).id_task, __VA_ARGS__)
#define SLT_DBG(slot, fmt, ...) VLOG(300)<<NOPREFIX<<NONEWLINE<<turbo::str_format("slot %12.*s: id %2d | task %d | " fmt, 12, __func__, (slot).id, (slot).id_task, __VA_ARGS__)

#define SRV_INF(fmt, ...) LOG(INFO)<<turbo::str_format("kmc  %12.*s: " fmt, 12, __func__, __VA_ARGS__)
#define SRV_WRN(fmt, ...) LOG(WARNING)<<turbo::str_format("kmc  %12.*s: " fmt, 12, __func__, __VA_ARGS__)
#define SRV_ERR(fmt, ...) LOG(ERROR)<<turbo::str_format("kmc  %12.*s: " fmt, 12, __func__, __VA_ARGS__)
#define SRV_DBG(fmt, ...) VLOG(300)<<turbo::str_format("kmc  %12.*s: " fmt, 12, __func__, __VA_ARGS__)

#define QUE_INF(fmt, ...) LOG(INFO)<<turbo::str_format("que  %12.*s: " fmt, 12, __func__, __VA_ARGS__)
#define QUE_WRN(fmt, ...) LOG(WARNING)<<turbo::str_format("que  %12.*s: " fmt, 12, __func__, __VA_ARGS__)
#define QUE_ERR(fmt, ...) LOG(ERROR)<<turbo::str_format("que  %12.*s: " fmt, 12, __func__, __VA_ARGS__)
#define QUE_DBG(fmt, ...) VLOG(300)<<turbo::str_format("que  %12.*s: " fmt, 12, __func__, __VA_ARGS__)


#define LOG_INF(...)  LOG(INFO)<<NOPREFIX<<NONEWLINE<<turbo::str_format(__VA_ARGS__)
#define LOG_WRN(...) LOG(WARNING)<<NOPREFIX<<NONEWLINE<<turbo::str_format(__VA_ARGS__)
#define LOG_ERR(...) LOG(ERROR)<<NOPREFIX<<NONEWLINE<<turbo::str_format(__VA_ARGS__)
#define LOG_DBG(...) VLOG(300)<<NOPREFIX<<NONEWLINE<<turbo::str_format(__VA_ARGS__)


namespace kllm {

    inline void enable_debug_log() {
        turbo::set_flag(&FLAGS_verbosity, 301);
    }
    inline void disable_debug_log() {
        turbo::set_flag(&FLAGS_verbosity, 0);
    }

}

